package nl.project.data;

import nl.project.data.controller.MembersDAO;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class Teacher extends User {
	private int teacherId;

	public Teacher(int id) throws EntityNotFoundException {
		this.teacherId = id;

		// get all info from this Teacher
		getTeacherInfo();
	}

	/**
	 * Get all the info from a certain teacher
	 * 
	 * @throws EntityNotFoundException
	 */

	private void getTeacherInfo() throws EntityNotFoundException {
		Key k = KeyFactory.createKey("Teachers", "Teachers");
		Entity e = MembersDAO.getEntityInfo(this.teacherId, k, "teacherId",
				"Teacher");
		this.initials = (String) e.getProperty("initials");
		this.firstName = (String) e.getProperty("firstName");
		this.surName = (String) e.getProperty("surName");
		this.title = (String) e.getProperty("title");
		this.preposition = (String) e.getProperty("preposition");
	}
}